<?php
class BoundItems {

	public static function add($data){
		return Db::get(__CLASS__)->insert($data)->exec() ;
	}

	public static function lastErr(){
		return Db::get(__CLASS__)->lastSql();
	}

	public static function getByBound($bound_id){
		return Db::get(__CLASS__)->select()->where(array('bound_id'=>$bound_id))
				->order('sno ASC')->hkey('ware_id')->getAll();
	}
	
	static function deleteByBound($bound_id){
		return Db::get(__CLASS__)->delete()->where(array('bound_id'=>$bound_id))->exec()
				&& Db::get(__CLASS__)->affectedRows() ? true : false;
	}
	
	public static function update($bound_id, $ware_id, $data){
		return Db::get(__CLASS__)->update($data)->where(array('bound_id'=>$bound_id,'ware_id'=>$ware_id))->exec()
			&& Db::get(__CLASS__)->affectedRows()>0 ? true: false;
	}
	
}
?>
